package com.lingyu.jsjx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lingyu.jsjx.domain.CourseReform;
import com.lingyu.jsjx.service.ICourseReformService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 课程改革
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/courseReform")
public class CourseReformController extends BaseController
{
    @Autowired
    private ICourseReformService courseReformService;

    /**
     * 查询课程改革列表
     */
    @RequiresPermissions("jsjx:courseReform:list")
    @GetMapping("/list")
    public TableDataInfo list(CourseReform courseReform)
    {
        startPage();
        List<CourseReform> list = courseReformService.selectCourseReformList(courseReform);
        return getDataTable(list);
    }

    /**
     * 导出课程改革列表
     */
    @RequiresPermissions("jsjx:courseReform:export")
    @Log(title = "课程改革", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseReform courseReform)
    {
        List<CourseReform> list = courseReformService.selectCourseReformList(courseReform);
        ExcelUtil<CourseReform> util = new ExcelUtil<CourseReform>(CourseReform.class);
        util.exportExcel(response, list, "课程改革数据");
    }

    /**
     * 获取课程改革详细信息
     */
    @RequiresPermissions("jsjx:courseReform:query")
    @GetMapping(value = "/{reformId}")
    public AjaxResult getInfo(@PathVariable("reformId") Long reformId)
    {
        return success(courseReformService.selectCourseReformByReformId(reformId));
    }

    /**
     * 新增课程改革
     */
    @RequiresPermissions("jsjx:courseReform:add")
    @Log(title = "课程改革", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseReform courseReform)
    {
        return toAjax(courseReformService.insertCourseReform(courseReform));
    }

    /**
     * 修改课程改革
     */
    @RequiresPermissions("jsjx:courseReform:edit")
    @Log(title = "课程改革", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseReform courseReform)
    {
        return toAjax(courseReformService.updateCourseReform(courseReform));
    }

    /**
     * 删除课程改革
     */
    @RequiresPermissions("jsjx:courseReform:remove")
    @Log(title = "课程改革", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reformIds}")
    public AjaxResult remove(@PathVariable Long[] reformIds)
    {
        return toAjax(courseReformService.deleteCourseReformByReformIds(reformIds));
    }

    @GetMapping(value = "/queryCountByCollage")
    public AjaxResult queryCountByCollage() {
        return success(courseReformService.selectCountByCollage());
    }
}
